//
//  ShareViewAdapter.m
//  Weibbo
//
//  Created by 李 林刚 on 13-8-11.
//  Copyright (c) 2013年 Omnivores. All rights reserved.
//

#import "ShareViewAdapter.h"
#import "ShareViewCell.h"

@interface ShareViewAdapter ()<ShareViewCellDelegate>

@end

@implementation ShareViewAdapter
@synthesize adapterDelegate;

-(id)initWithList:(NSArray *)data andAdapter:(id)adapter
{
    self =  [super initWithList:data andAdapter:adapter];
    if (self) {
        adapterDelegate = adapter;
    }
    return self;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [_list count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *defaultCellIdentifier = @"ShareViewCell";
    ShareViewCell *cell = [tableView dequeueReusableCellWithIdentifier:defaultCellIdentifier];
    if (cell == nil)
    {
        cell = [[[ShareViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:defaultCellIdentifier]autorelease];
        cell.delegate = self;
        cell.textLabel.font = UIFontOfSize(18);
        [cell.textLabel setTextAlignment:NSTextAlignmentLeft];
        [cell.textLabel setTextColor:UIBlackColor];
    }
    [cell.textLabel setText:[_list objectAtIndex:indexPath.row]];
    if (indexPath.row<2) {
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        if (indexPath.row==0) cell.tag = ShareTypeSina;
        else cell.tag = ShareTypeTencentOAuth;
        [cell setSwitchViewHiden:YES];
    }
    else
    {
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        [cell setSwitchViewHiden:NO];
    }
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 48.0f;
}


#pragma mark  --------ShareViewCellDelegate
-(void)ShareViewCellDelegateOpenAlbum:(BOOL)IsOpen
{
    if ([adapterDelegate respondsToSelector:@selector(ShareViewAdapterDelegateSaveToAlbum:)]) {
        [adapterDelegate ShareViewAdapterDelegateSaveToAlbum:IsOpen];
    }
}
@end
